package com.shangma.utils;

import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class MyTask {
//    @Scheduled(cron = "0/5 * * * * ?")
//    @Async
    public void task1() {
        System.out.println("当前线程是" + Thread.currentThread().getName() + "\ttask1正在执行");
        try {
            Thread.sleep(20000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

//    @Scheduled(cron = "3/5 * * * * ?")
//    @Async
    public void task2(){
        System.out.println("当前线程是" + Thread.currentThread().getName() + "\ttask2正在执行");
    }

}
